package com.library.control.book;

import java.util.ArrayList;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.AbstractController;

import com.library.model.dto.book.BookDTO;
import com.library.model.service.BookService;

public class BookListController extends AbstractController {

	private BookService bookservice;
	
	public void setBookservice(BookService bookservice) {
		this.bookservice = bookservice;
	}

	@Override
	protected ModelAndView handleRequestInternal(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		ModelAndView mav=new ModelAndView();
		List<BookDTO> list=new ArrayList<BookDTO>();
		list=bookservice.getAllBook();
		mav.addObject("books",list);
		mav.setViewName("booklist");
		return mav;
	}

}
